﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace RescueRobotController.panels
{
    public partial class EmergencyStopPanel : DockContent, IReceivedATCmd
    {
        // “急停按钮被按下”事件
        public delegate void EmergencyStopPushedHandler();
        public event EmergencyStopPushedHandler EmergencyStopPushed;

        /* 下面的内容是每个面板必须要有的 */
        // *********** BEGIN ************* //
        // “发送AT指令”事件
        public delegate void ExistATCmdToSendHandler(ATCmd cmd);
        public event ExistATCmdToSendHandler SendATCmd;

        // 处理AT指令
        public void HandleATCmd(ATCmd cmd)
        {

        }
        // *********** END ************* //

        public EmergencyStopPanel()
        {
            InitializeComponent();
        }

        private void picture_emergencystop_MouseDown(object sender, MouseEventArgs e)
        {
            picture_emergencystop.BackColor = Color.DarkGray;
        }

        // 鼠标松开时触发事件
        private void picture_emergencystop_MouseUp(object sender, MouseEventArgs e)
        {
            picture_emergencystop.BackColor = Color.LightGray;

            // 调用急停按钮被按下事件
            if (EmergencyStopPushed != null)
                EmergencyStopPushed();
            SendATCmd(new ATCmd() { type = ATCmdType.EXEC, target = "STOP" });
        }
    }
}
